/** *******************************************************************
 * Amfphp Redux
 * @author  Jonnie Spratley
 * @see jonniespratley@gmail.com
 * @internal
 ******************************************************************* */
package com.jonniespratley.amfphpredux.control
{
	import com.adobe.cairngorm.control.FrontController;
    import com.jonniespratley.amfphpredux.commands.*;
    import com.jonniespratley.amfphpredux.events.*;
	
	/**
	 * The Front Controller is a central place where all the commands are mapped to
	 * the relevant events. Once an event is dispatched, the Front Controller finds
	 * the corresponding command to execute.
	 */	
	public final class AmfphpReduxController extends FrontController
	{
		public function AmfphpReduxController()
		{
			this.initialize();
		}

		private function initialize() : void
		{
			//Map events.WHAT TYPE OF EVENT, to COMMAND
			this.addCommand( GetServicesEvent.GET_SERVICES_EVENT, GetServicesCommand );
		    this.addCommand( SelectedServiceEvent.SELECTED_SERVICE_EVENT, SelectedServiceCommand );
			
		    this.addCommand( DescribeServicesEvent.DESCRIBE_SERVICES_EVENT, DescribeServicesCommand );

		    this.addCommand( GetDatabasesEvent.GET_DATABASES_EVENT, GetDatabasesCommand );

		    this.addCommand( GetTablesEvent.GET_TABLES_EVENT, GetTablesCommand );
		    this.addCommand( SaveGatewayURLEvent.SAVE_GATEWAY_URL_EVENT, SaveGatewayURLCommand );
		    this.addCommand( SetEndpointURLEvent.SET_ENDPOINT_URL_EVENT, SetEndpointURLCommand );
		    this.addCommand( SendRequestEvent.SEND_REQUEST_EVENT, SendRequestCommand );
		    
		    this.addCommand( SelectedMethodEvent.SELECTED_METHOD_EVENT, SelectedMethodCommand );
		    //todo: add commands
		}
	}
}
